<html>
<head>
<script language="JavaScript">
function CheckForm(){
	//检查会员名是否为空
	if(document.form1.txtname.value.length == 0){
	alert("会员名不能为空，请输入会员名!");
	document.form1.txtname.focus();
	return false;
	}
	if(document.form1.txtname.value.length<5 || document.form1.txtname.value.length>20){
	alert("会员名必须是5~20个字符以内!");
	document.form1.txtname.value = "";
	document.form1.txtname.focus();
	return false;
	}
	var repPass = /[0-9a-zA-Z]{6,16}/;
	var repPass1 = /[0-9{1,}]/;
	var repPass2 = /[a-zA-Z]{1,}/;
	if(document.form1.txtpassword.value.length<6 || document.form1.txtpassword.value.length>20){
	alert("密码长度不符合要求!");
	document.form1.txtpassword.value = "";
	document.form1.txtpassword.focus();
	return false;
}
if(!repPass.test(document.form1.txtpassword.value) || (document.form1.txtpassword.value == null)){
	alert("!请输入符合规则的密码");
	document.form1.txtpassword.value = "";
	document.form1.txtpassword.focus();
	return false;}
if(!repPass1.test(document.form1.txtpassword.value) || !repPass2.test(document.form1.txtpassword.value)){
	alert("请输入符合规则的密码!");
	document.form1.txtpassword.value = "";
	document.form1.txtpassword.focus();
	return false;
	}
if(document.form1.txtpassword.value != document.form1.txtpwd.value){
	alert("两个密码不同！请输入密码!");
	document.form1.txtpassword.value = "";
	document.form1.txtpwd.focus();
	return false;
}
	var email_str = document.form1.txtmail.value
	if (email_str.indexOf("@") == -1){
	alert("电子邮件的格式不对!");
	document.form1.txtmail.focus();
	return false;
	}
	if(document.form1.txtcheck.value != document.form1.txtinput.value){
	alert("验证码错误!");
	document.form1.txtcheck.focus();
	return false;
	}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表单验证</title>

<style type="text/css">
<!--
.style1 {
	font-family: "黑体";
	font-size: 20px;
	color: #666;
}
.style2 {
	font-family: "宋体";
	font-size: 12px;
	text-align: right;
}
.style3 {
	font-family: "黑体";
	color: #FFF;
	font-size: 18px;
}
#copyright {
	text-align: center;
	color: #CCC;
}
.style4 {
	font-family: "宋体";
	font-size: 12px;
	color: #999;
	float:right;
}
#form1 table tr td .style2 {
	color: #999;
}
-->
</style>
</head>
<body topmargin="0">
<table width="100%" border="0" align="left" cellpadding="5">
  <tr>
    <td height="40"><img src="logo.png" width="140" height="35">&nbsp;&nbsp;&nbsp;&nbsp;<span class="style1">注册</span></td>
  </tr>
  <tr>
    <td height="40" bgcolor="#FF784A" class="style3">第一步：填写账户信息</td>
  </tr>
  <tr>
    <td height="300"><form id="form1" name="form1" method="post" action="">
      <table  width="90%" height="280" border="0" align="center">
        <tr>
          <td width="100">会 &nbsp;员 &nbsp;名：</td>
          <td>
            <label>
              <input name="txtname" type="text" id="txtname" size="20" />
            </label>
            <label class="style2">(5~20个字符以内！)</label>
          </td>
          </tr>
        <tr>
          <td>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
          <td><label>
            <input name="txtpassword" type="password" id="txtpassword" size="22" />
          </label>
            <label class="style2">(<span class="attention">6-16个字符，请使用字母加数字或符号的组合密码，不能单独使用字母、数字或符号。</span>)</label></td>
          </tr>
        <tr>
          <td>确认密码：</td>
          <td><label>
            <input name="txtpwd" type="password" id="txtpwd" size="22" />
          </label></td>
          </tr>
          <tr>
          <td >电子邮箱：</td>
          <td ><label>
            <input name="txtmail" type="text" id="txtmail" size="20" />
          </label></td>
          </tr>
        <tr>
          <td>验&nbsp;&nbsp;证&nbsp;&nbsp;码：</td>
          <td><label>
            <input name="txtcheck" type="text" id="txtcheck" size="10" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="style2">
            随机产生的验证码为</span>
            <input name="txtinput" type="text" class="style2" id="txtinput" size="6" />
          </label>
         <Script Language="JavaScript">
	var num = 0;
	 num = Math.floor(Math.random()*10000);
	 document.form1.txtinput.value = num;
</Script>
          </td>
          </tr>
        <tr>
          <td colspan="2" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <label>
              <input type="submit" name="button" id="button" value="注册" onClick="CheckForm()" />
          </label></td>
          </tr>     
      </table>
    </form>
    </td>
  </tr>
  <tr>
    <td height="30" bgcolor="#FF784A"><div class="style2" id="copyright">Copyright ? 2003-2011 Taobao.com 版权所有</div></td>
  </tr>
</table>
</body>
</html>

